<!--<?php
include_once PrintEot('header');
if(empty($action)){
print <<<EOT
-->
<form action="$admin_file" method="post" name="form">

    <table border="0" cellpadding="0" cellspacing="0" width="100%">
        <tr>
            <td align="left" class="tittab">
                <strong>广告计划管理 &gt;&gt; 广告创意管理</strong>
            </td>
        </tr>
    </table>
    <table id="Table50" border="0" cellpadding="0" cellspacing="1" width="97%" align=center>
         <tr>
            <td colspan=2 height=30 class="zmenu"><b>数据分类：</b>
<!--
EOT;
 showPageLink("all", "1", "全部数据");
 showPageLink("status", "0", "暂停");
 showPageLink("status", "1", "运营中");  
print <<<EOT
-->
            </td></tr>
			<tr>
            <td><b>快速查询：</b><select id="searchtype" name="searchtype">
								<option value="name" selected>计划名称</option>
								<option value="shortname">客户简称</option>
								<option value="contractname">合同名称</option>							
							</select>
							<input type="text" name="searchkey" value="$searchkey" class="text"/>
							<input type="button" name="btnQuery" value="查询" class="text"/>
						</td>
            <td align="right" valign="center">
                <table id="Table51" border="0" cellpadding="0" cellspacing="5" height="30">
                    <input name="allSelect" type="hidden" value="all" />
                    <tr>
                        <td align="middle" valign="center">
                            <a href="javascript:document.location.reload();">
                                <img align="absMiddle" border="0" height="15" src="$imgpath/admin/reserch.gif" style="text-decoration: underline" width="17" />
                                <span style="color: #547054"> 刷新</span></a>
<!--
EOT;
						if($canaudit==true){
							showButton(4,'启用','javascript:ConfirmDel("'.$admin_file.'&action=changestatus&auditstatus=1'.$transtr.'&curpage='.$curpage.'","是否确认启用选中的创意？");');
						}
						if($canadd==true){
							showButton(1,'新增',$admin_file.'&action=new'.$transtr);
						}
						if($candel==true){
							showButton(2,'删除','javascript:ConfirmDel("'.$admin_file.'&action=del'.$transtr.'&Page='.$curpage.'","此操作不可恢复,确认删除吗？");');
						}print <<<EOT
-->
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr>
            <td height="2" colspan=2>
            </td>
        </tr>
    </table>
    <div class="tab">
        <table id="Table52" border="0" cellpadding="3" cellspacing="0" align=center>
            <tr>
                <td align="middle" class="title" height="20" valign="center">序号</td>
                <td align="middle" class="title" height="20" valign="center">
                    <input id="Checkbox1" name="as" onclick="allchecked()" type="checkbox" />全选
                </td>
                <td align="middle" class="title" height="20" valign="center">创意名称</td>                
                <td align="middle" class="title" height="20" valign="center">广告计划</td>
                <td align="middle" class="title" height="20" valign="center">广告主</td>
                <td align="middle" class="title" height="20" valign="center">内容类型</td>                 
                <td align="middle" class="title" height="20" valign="center">创意分类</td>               
                <td align="middle" class="title" height="20" valign="center">尺寸</td>
                <td align="middle" class="title" height="20" valign="center">创建时间</td>                  
                <td align="middle" class="title" height="20" valign="center">更新时间</td>  
                <td align="middle" class="title" height="20" valign="center">导向页面</td>                                               
                <td align="middle" class="title" height="20" valign="center">创建人</td>
                <td align="middle" class="title" height="20" valign="center">状态</td>                
                <td align="middle" class="title" height="20" valign="center">操作</td>
            </tr>
<!--
EOT;
$curidx = ($curpage-1)*$perpage;
$curpageidx = 0;
$showcount = count($db_advcreativelist); 
foreach($db_advcreativelist as $db_advcreative ){
	$curidx = $curidx+1;
	$curpageidx = $curpageidx+1;
	$udate = date('Y/m/d H:i:s',$db_advcreative[update_time]);
	$cdate = date('Y/m/d H:i:s',$db_advcreative[create_time]);	
	$advctistatus = $cfg_advstatus[$db_advcreative[status]];	
	$advctitype = $cfg_advctitype[$db_advcreative[content_type]];
print <<<EOT
--> 
            <tr height="20"  onclick="SwitchTd(this,'click',$curpageidx);" onmouseout="SwitchTd(this,'out',$curpageidx);" onmouseover="SwitchTd(this,'over',$curpageidx);" style="cursor: hand">
                <td align="middle" valign="center" height="20">$curidx </td>
                <td align="middle" valign="center"><input id="ids" name="ids" type="checkbox" value="$db_advcreative[id]" /></td>
                <td align="middle" valign="center">&nbsp;$db_advcreative[name]</td>
                <td align="middle" valign="center">&nbsp;<a href="$basename?job=detail&action=advertise&curid=$db_advcreative[adv_id]$transtr&backurl=$backurl" class=NoLine>$db_advcreative[adv_name]</a></td>
                <td align="middle" valign="center">&nbsp;<a href="$basename?job=detail&action=merchant&curid=$db_advcreative[mer_id]$transtr&backurl=$backurl" class=NoLine>$db_advcreative[mer_name]</a></td>
                <td align="middle" valign="center">&nbsp;$advctitype</td>
                <td align="middle" valign="center">&nbsp;$db_advcreative[adformat]</td>
                <td align="middle" valign="center">&nbsp;$db_advcreative[adsize]</td>
                <td align="middle" valign="center">&nbsp;$cdate</td> 
                <td align="middle" valign="center">&nbsp;$udate</td>
                <td align="middle" valign="center">&nbsp;$db_advcreative[pageurl]</td>
                <td align="middle" valign="center">&nbsp;$db_advcreative[creator_user]</td> 
     			<td align="middle" valign="center">&nbsp;$advctistatus</td>                                                 
                <td align="middle" valign="center">&nbsp;
<!--
EOT;
	showEditButton($db_advcreative[id]);
print <<<EOT
-->
                </td>
            </tr>
<!--
EOT;
}print <<<EOT
-->
        </table>
    </div>
    <table id="Table1" border="0" cellpadding="0" cellspacing="0" width="98%">
        <tr>
            <td>
                &nbsp;</td>
            <td align="right" height="35">
<!--
EOT;
	showPageBreakInfo($showcount);
print <<<EOT
-->
             &nbsp;</td>
        </tr>
    </table>
    <input type="hidden" id="count" name="count" value="$showcount" />

</form>


<!--
EOT;
}
if($action=="new" || $action=="edit"){
print <<<EOT
-->
<form action="$admin_file" method="post" name="form" onsubmit="return checkfrm();" enctype="multipart/form-data">
<input type="hidden" name="action" id="action" value="save"/>
<input type="hidden" name="curid" id="curid" value="$curid"/>
<TABLE cellSpacing="0" cellPadding="0" width="100%" border=0 ID="Table22">
	<TBODY>
		<TR >
			<TD class="tittab" BACKGROUND="$imgpath/admin/menu_bg.gif"><strong><img src="$imgpath/admin/view.gif" width="15" height="13" align="absmiddle"> 新增/编辑　活动创意</strong></TD>
		</TR>
	</TBODY>
</TABLE>
<table cellspacing=0 cellpadding=0 width="100%" border=0 id="Table23">  
    <tbody>
      <tr>
        <td valign=top width="50%">
		<div class="addpro">
		<table cellspacing=0 cellpadding=4 width="100%" border=0 align=center id="Table24">
        <tbody>
				<tr>
					<td align=right width=30%>所属广告计划(<font color="red">*</font>)：</td>
					<td>
						<select id="adv_id" name="adv_id" style="width:235px"><option value="">请选择...</option>$op_advlist</select>
					</td>
				</tr>
				<tr>
					<td align=right width=30%>创意名称(<font color="red">*</font>)：</td>
					<td>
					    <input type="text" id="name" name="name" style="width:235px" value="$db_advcreative[name]"/>
					</td>
				</tr>
				<tr>			
					<td align=right>广告格式(<font color="red">*</font>)：</td>
					<td>
					    <select id="adformat" name="adformat" style="width:235px"><option value="">请选择...</option>$op_advformatlist</select>
					</td>
				</tr>
				<tr>					
					<td align=right>内容类型(<font color="red">*</font>)：</td>
					<td>
<!--
EOT;
	if(!isset($db_advcreative) || $db_advcreative[content_type]==0){
		echo '<input type="radio" id="content_type0" name="content_type" value="0" onclick="showHideDiv(0)" checked/><label for="content_type0" onclick="showHideDiv(0);">文字</label>';
	}else{
		echo '<input type="radio" id="content_type0" name="content_type" value="0" onclick="showHideDiv(0)"/><label for="content_type0" onclick="showHideDiv(0);>文字</label>';
	}
	if(isset($db_advcreative) && $db_advcreative[content_type]==1){
		echo '<input type="radio" id="content_type1" name="content_type" value="1" onclick="showHideDiv(1)" checked/><label for="content_type1" onclick="showHideDiv(1);">图片</label>';
	}else{
		echo '<input type="radio" id="content_type1" name="content_type" value="1" onclick="showHideDiv(1)"/><label for="content_type1" onclick="showHideDiv(1);">图片</label>';
	}
	if(isset($db_advcreative) && $db_advcreative[content_type]==2){
		echo '<input type="radio" id="content_type2" name="content_type" value="2" onclick="showHideDiv(2)" checked/><label for="content_type2" onclick="showHideDiv(2);">原始代码</label>';
	}else{
		echo '<input type="radio" id="content_type2" name="content_type" value="2" onclick="showHideDiv(2)"/><label for="content_type2" onclick="showHideDiv(2);">原始代码</label>';
	}
	//$demourl = urlencode($cfg_domain.$cfg_vdir."/admin/blank.php");
print <<<EOT
-->
					</td>
				</tr>
				<tr>							
					<td align=right>创意内容(<font color="red">*</font>)：</td>
					<td>
<!--
EOT;
	$word_display="display:none";$img_display="display:none";$code_display="display:none";
	if(!isset($db_advcreative) || $db_advcreative[content_type]==0) $word_display = "display:block";
	if(isset($db_advcreative) && $db_advcreative[content_type]==1) $img_display = "display:block";
	if(isset($db_advcreative) && $db_advcreative[content_type]==2) $code_display = "display:block";
print <<<EOT
-->
<div id="div0" style="$word_display"><input id="txt_word" name="txt_word" style="width:205px" value="$db_advcreative[res_content]"/>&nbsp;<a href="#" onclick="PreView(0);">预览</a></div>
<div id="div1" style="$img_display"><input type="file" id="img_file" name="img_file" style="width:205px"/>&nbsp;<a href="#" onclick="PreView(1);">预览</a></div>
<div id="div2" style="$code_display"><textarea name="txt_code" id="txt_code" style="width:205px;height:60px">&nbsp;</textarea><a href="#" onclick="PreView(2);">预览</a></div>
					</td>
				</tr>
				<tr>							
					<td align=right>导向页面：</td>
					<td>
					    <select id="page_id" name="page_id" style="width:235px"><option value="">请选择...</option>$op_advpagelist</select>
					</td>
				</tr>
				<tr id="tdsize" style="display:none">
					<td align=right>广告尺寸(<font color="red">*</font>)：</td>
					<td>
					    <select id="adsize" name="adsize" style="width:235px"><option value="">请选择...</option>$op_advsizelist</select>
					</td>	
				</tr>
				<tr>
					<td align=right>创意说明：</td>
					<td>
						<textarea id="memo" name="memo" cols="45" rows="6"/>$db_advcreative[memo]</textarea>
					</td>
				</tr>
				<tr>
					<td align=right>广告代码：</td>
					<td><textarea id="demo_code" name="demo_code" cols="45" rows="6" onmouseover="this.select();" readonly/>
<!--
EOT;
	$advcode = "";
	if(isset($db_advcreative) && $db_advcreative[content_type]==0){
		//$t = pwdCode($timestamp+$sec*10+intval($millsec*100000000));
		$advcode = '&lt;a href="'.$cfg_domain.$cfg_vdir.'/i/?act=1&amp;id='.$curid.'-{aff_id}-{site_id}-{place_id}&amp;c={vali_code}"&gt;'.$db_advcreative[res_content].'&lt;/a&gt;';
		$code = urlencode($advcode);		
	}
	if(isset($db_advcreative) && $db_advcreative[content_type]==1){
		$advcode = '&lt;a href="'.$cfg_domain.$cfg_vdir.'/i/?act=1&amp;id='.$curid.'-{aff_id}-{site_id}-{place_id}&amp;c={vali_code}"&gt;&lt;img src="'.$cfg_domain.$cfg_vdir.'/i/?act=0&amp;id='.$curid.'-{aff_id}-{site_id}-{place_id}&amp;c={vali_code}"/&gt;&lt;/a&gt;';
		$imgcode =  '&lt;a href="'.$cfg_domain.$cfg_vdir.'/i/?act=1&amp;id='.$curid.'-{aff_id}-{site_id}-{place_id}&amp;c={vali_code}"&gt;&lt;img border="0" src="'.$cfg_vdir.$db_advcreative[res_content].'"/&gt;&lt;/a&gt;';
		$code = urlencode($imgcode);
	}
	if(isset($db_advcreative) && $db_advcreative[content_type]==2){
			$advcode = str_replace("{aff_id}",$aff_id,$db_advplace[res_content]);
			$advcode = str_replace("{site_id}",$site_id,$advcode);
			$advcode = str_replace("{place_id}",$site_id,$advcode);
			$advcode = str_replace("{vali_code}",$valicode,$advcode);
	}

print <<<EOT
-->$advcode</textarea>
					</td>
				</tr>
				<tr>
					<td colspan="2" align="center">
						<input type="submit" id="btnSubmit" value=" 确定 " name="btnSubmit">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
						<input type="button" onclick="history.go(-1);" value=" 取消 ">
					</td>
				</tr>
    </tbody>

 </TABLE>  
 </div>

    </TD>
    <td align="center" valign="middle" width="40%">
    <center>
    	<iframe id="framecode" frameborder="0" src="$admin_file&action=innercode&code=$code" height="480px" width="100%" SCROLLING=NO ></iframe>
    </center>
	</td>
    </TR></TBODY></TABLE>  

 </form>

<script type="text/javascript" language=javascript>
function PreView(type){
	var id = "$curid";
	if(id=="") id = "{crt_id}";
	if(type==0 && isEmpty($("txt_word"))==false){
		var code =  '<a href="$cfg_domain$cfg_vdir/i/?act=1&id='+id+'-{aff_id}-{site_id}-{place_id}&c={vali_code}">'+$("txt_word").value+'</a>';
		var framecode = '&lt;a href="$cfg_domain$cfg_vdir/i/?act=1&id='+id+'-{aff_id}-{site_id}-{place_id}&c={vali_code}"&gt;'+$("txt_word").value+'&lt;/a&gt;';
		$("demo_code").value = code;
		$("framecode").src = "$admin_file&action=innercode&code="+encodeURIComponent(framecode);
	}
	if(type==1 && isEmpty($("img_file"))==false){
		var code =  '<a href="$cfg_domain$cfg_vdir/i/?act=1&id='+id+'-{aff_id}-{site_id}-{place_id}&c={vali_code}"><img src="http://$cfg_domain$cfg_vdir/i/act=0&id='+id+'-{aff_id}-{site_id}-{place_id}&c={vali_code}" border ="0"/></a>';
		var framecode = '&lt;a href="$cfg_domain$cfg_vdir/i/?act=1&id='+id+'-{aff_id}-{site_id}-{place_id}&c={vali_code}"&gt;&lt;img src="'+$("img_file").value+'"/&gt;&lt;/a&gt;';
		$("demo_code").value = code;
		$("framecode").src = "$admin_file&action=innercode&code="+encodeURIComponent(framecode);
	}
	if(type==2 && isEmpty($("txt_code"))==false){
		var code = $("txt_code").value;
		$("demo_code").value = code;
		$("framecode").src = "$admin_file&action=innercode&code="+encodeURIComponent(framecode);
	}
}
function checkfrm(){
	if(isEmpty($('adv_id').value)==true){
		alert('请选择广告计划！');
		$('adv_id').focus();
		return false;
	}	
	if(isEmpty($('name').value)==true){
		alert('请输入创意名称！');
		$('name').focus();
		return false;
	}
	if(isEmpty($('adformat').value)==true){
		alert('请选择广告格式！');
		$('adformat').focus();
		return false;
	}
	if($('content_type0').checked && isEmpty($('txt_word').value)){
		alert('请输入文字内容！');
		$('txt_word').focus();
		return false;
	}
	if($('content_type1').checked && isEmpty($('img_file').value)){
		alert('请上传图片内容！');
		$('img_file').focus();
		return false;
	}
	if($('content_type2').checked && isEmpty($('txt_code').value)){
		alert('请输入原始代码内容！');
		$('txt_code').focus();
		return false;
	}
	if($('content_type0').checked==false && isEmpty($('adsize').value)==true){
		alert('请选择广告尺寸！');
		$('adsize').focus();
		return false;
	}
    return true;
}
function showHideDiv(selidx){
	if(selidx>0) $('tdsize').show();
	else $("tdsize").hide();
	for(var i=0;i<3;i++){
		if(selidx==i){
			$('div'+i).style.display='block';
		}else{
			$('div'+i).style.display='none';
		}
	}
}
</script>

<!--
EOT;
}?>-->